package com.tangding.hprose.api.server.command;

import com.tangding.common.tools.ErrorConstants;

/**
 * @description 
 *
 * @author Ranger
 * @version 2017年7月5日_下午9:09:08
 *
 */
public class Response {
	
	/**结果代码*/
	private int code;
	
	/**结果代码描述*/
	private String msg;
	
	/**返回值*/
	private Object data;
	
	public Response() {
		super();
	}

	public Response(int code, String msg) {
		super();
		this.code = code;
		this.msg = msg;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public static Response responseSuccess() {
		return new Response(ErrorConstants.SUCC, "succ!");
	}

	public static Response responseSuccess(Object data) {
		Response dto = new Response(ErrorConstants.SUCC, "succ!");
		dto.setData(data);
		return dto;
	}

	public static Response responseFail(String msg) {
		return new Response(ErrorConstants.FAIL, msg);
	}

	public static Response responseFail(int code) {
		return new Response(code, ErrorConstants.getDesc(code));
	}
	
	public static Response responseFail(int code, String msg) {
		return new Response(code, msg);
	}
}
